HAL SMARTCARD types migration ¶
This section provides information about the HAL SMARTCARD types migration.
HAL SMARTCARD callback ID type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_SMARTCARD_TX_COMPLETE_CB_ID
HAL_SMARTCARD_RX_COMPLETE_CB_ID
HAL_SMARTCARD_ERROR_CB_ID
HAL_SMARTCARD_ABORT_COMPLETE_CB_ID
HAL_SMARTCARD_ABORT_TRANSMIT_COMPLETE_CB_ID
HAL_SMARTCARD_ABORT_RECEIVE_COMPLETE_CB_ID
HAL_SMARTCARD_RX_FIFO_FULL_CB_ID
HAL_SMARTCARD_TX_FIFO_EMPTY_CB_ID
HAL_SMARTCARD_MSPINIT_CB_ID
HAL_SMARTCARD_MSPDEINIT_CB_ID
} HAL_SMARTCARD_CallbackIDTypeDef;
|
Removed. Note The callback registration in HAL2 is handled by specific functions for each SMARTCARD event. See Register Callbacks for more details.
|
Related concepts:
HAL SMARTCARD state type definition ¶
- In HAL2, key changes include:
-
Renaming of several states.
Removal of states
HAL_SMARTCARD_STATE_TIMEOUTandHAL_SMARTCARD_STATE_ERROR.Adding a new state
HAL_SMARTCARD_STATE_ABORT
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_SMARTCARD_STATE_RESET
HAL_SMARTCARD_STATE_READY
HAL_SMARTCARD_STATE_BUSY
HAL_SMARTCARD_STATE_BUSY_TX
HAL_SMARTCARD_STATE_BUSY_RX
HAL_SMARTCARD_STATE_BUSY_TX_RX
HAL_SMARTCARD_STATE_TIMEOUT
HAL_SMARTCARD_STATE_ERROR
}HAL_SMARTCARD_StateTypeDef;
|
typedef enum
{
HAL_SMARTCARD_STATE_RESET
HAL_SMARTCARD_STATE_INIT
HAL_SMARTCARD_STATE_IDLE
HAL_SMARTCARD_STATE_RX_ACTIVE
HAL_SMARTCARD_STATE_TX_ACTIVE
HAL_SMARTCARD_STATE_ABORT
} hal_smartcard_state_t;
|
Related concept: Revised and optimized HAL state machine
HAL SMARTCARD clock source type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
SMARTCARD_CLOCKSOURCE_PCLK1,
SMARTCARD_CLOCKSOURCE_HSI,
SMARTCARD_CLOCKSOURCE_SYSCLK,
SMARTCARD_CLOCKSOURCE_LSE,
SMARTCARD_CLOCKSOURCE_UNDEFINED
.
.
.
} SMARTCARD_ClockSourceTypeDef;
|
Removed: In HAL1, this structure was used internally for baudrate calculations and was not exposed to the user. |
Related concept: Define statements and enumerations redirected to LL equivalents
HAL SMARTCARD handle type definition ¶
|
HAL1 |
HAL2 |
|---|---|
SMARTCARD_HandleTypeDef;
|
hal_smartcard_handle_t
|
Related concepts:
HAL SMARTCARD initialization type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t BaudRate;
uint32_t StopBits;
uint16_t Parity;
uint16_t NACKEnable;
uint32_t ClockPrescaler;
uint8_t Prescaler;
uint16_t CLKPolarity;
uint16_t CLKPhase;
uint8_t GuardTime;
uint8_t AutoRetryCount;
uint16_t Mode;
uint32_t WordLength;
uint16_t OneBitSampling;
uint16_t CLKLastBit;
uint32_t TimeOutEnable;
uint32_t TimeOutValue;
uint8_t BlockLength;
} SMARTCARD_InitTypeDef;
|
typedef struct
{
uint32_t baud_rate;
hal_smartcard_stop_bits_t stop_bits;
hal_smartcard_parity_t parity;
hal_smartcard_nack_state_t nack;
hal_smartcard_prescaler_t clock_prescaler;
hal_smartcard_source_clock_prescaler_t sclk_prescaler;
hal_smartcard_clock_polarity_t clock_polarity;
hal_smartcard_clock_phase_t clock_phase;
uint32_t guard_time_etu;
uint32_t auto_retry_count;
hal_smartcard_bit_order_t first_bit;
hal_smartcard_clock_output_t clock_output;
} hal_smartcard_config_t;
Removed Members: Removed : for more details see HAL SMARTCARD mode types constants Removed : for more details see HAL SMARTCARD word length options Removed : for more details see HAL SMARTCARD one bit sample constants Removed : for more details see HAL SMARTCARD last bit control constants Removed : for more details see HAL SMARTCARD timeout control constants Removed : for more details see HAL SMARTCARD block length |
Related concept: Replaced TypeDef suffix with _t in type names
HAL SMARTCARD advanced feature initialization type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t AdvFeatureInit;
uint32_t TxPinLevelInvert;
uint32_t RxPinLevelInvert;
uint32_t DataInvert;
uint32_t Swap;
uint32_t OverrunDisable;
uint32_t DMADisableonRxError;
uint32_t MSBFirst;
uint16_t TxCompletionIndication;
} SMARTCARD_AdvFeatureInitTypeDef;
|
This structure has been removed, along with its association as a member of the handle. Each advanced feature is now configured and controlled through specific functions, allowing direct management of these features without relying on the previous structure. For more information on enabling or disabling advanced features, see the section HAL SMARTCARD advanced features for more details on advanced feature management functions. |
Usage Sequence
|
HAL1 Usage |
HAL2 Usage |
|---|---|
SMARTCARD_HandleTypeDef hsmartcard1;
// Add your basic config to the handle
hsmartcard1.AdvancedInit.AdvFeatureInit = SMARTCARD_ADVFEATURE_TXINVERT_INIT |
SMARTCARD_ADVFEATURE_RXINVERT_INIT |
SMARTCARD_ADVFEATURE_DATAINVERT_INIT |
SMARTCARD_ADVFEATURE_SWAP_INIT |
SMARTCARD_ADVFEATURE_RXOVERRUNDISABLE_INIT |
SMARTCARD_ADVFEATURE_DMADISABLEONERROR_INIT |
SMARTCARD_ADVFEATURE_MSBFIRST_INIT |
hsmartcard1.AdvancedInit.TxPinLevelInvert = SMARTCARD_ADVFEATURE_TXINV_ENABLE;
hsmartcard1.AdvancedInit.RxPinLevelInvert = SMARTCARD_ADVFEATURE_RXINV_ENABLE;
hsmartcard1.AdvancedInit.DataInvert = SMARTCARD_ADVFEATURE_DATAINV_ENABLE;
hsmartcard1.AdvancedInit.Swap = SMARTCARD_ADVFEATURE_SWAP_ENABLE;
hsmartcard1.AdvancedInit.OverrunDisable = SMARTCARD_ADVFEATURE_OVERRUN_DISABLE;
hsmartcard1.AdvancedInit.DMADisableonRxError = SMARTCARD_ADVFEATURE_DMA_DISABLEONRXERROR;
hsmartcard1.AdvancedInit.MSBFirst = SMARTCARD_ADVFEATURE_MSBFIRST_ENABLE;
/* Initialization and configure basic and advanced configuration features selected */
HAL_SMARTCARD_Init(&hsmartcard1);
|
hal_smartcard_handle_t hsmartcard1;
hal_smartcard_config_t smartcard_config;
// Add your basic config
/* Initialization */
HAL_SMARTCARD_Init(&hsmartcard1,HAL_SMARTCARD1);
/* Basic configuration */
HAL_SMARTCARD_SetConfig(&hsmartcard1, &smartcard_config);
/* Configure and enable advanced features */
HAL_SMARTCARD_EnableIOInvert(&hsmartcard1);
Removed: The advanced RX inversion feature is removed as only one line is used for both transmission (TX) and reception (RX).
HAL_SMARTCARD_EnableDataInvert(&hsmartcard1);
HAL_SMARTCARD_EnableTxRxSwap(&hsmartcard1);
HAL_SMARTCARD_DisableRxOverRunDetection(&hsmartcard1);
HAL_SMARTCARD_EnableDMAStopOnRxError(&hsmartcard1);
Removed: the advanced MSB First feature is incorporated into the smartcard configuration structure hal_smartcard_config_t through the first_bit parameter
|
HAL SMARTCARD callback type definition ¶
|
HAL1 |
HAL2 |
|---|---|
|
pSMARTCARD_CallbackTypeDef |
hal_smartcard_cb_t |